// Created from GroupGenerationTemplate
// For Decisions HL7 Engine
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using DecisionsFramework.Design.Properties;
using Decisions.HL7.DataTypes;
using ST = System.String;
using SI = System.String;
using IS = System.String;
using ID = System.String;
using SNM = System.String;

namespace Decisions.HL7.Message
{
    [DataContract]
	public class RESPONSE_EHC_E13 : AbstractGroup
    {
        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("18 OBX",18)]
  	    [HL7Field(HL7Version.v26, 18, HL7Repeat.False, HL7Required.True,"OBX")]
	    public OBX OBX {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("19 NTE",19)]
  	    [HL7Field(HL7Version.v26, 19, HL7Repeat.False, HL7Required.False,"NTE")]
	    public NTE NTE {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("20 TXA",20)]
  	    [HL7Field(HL7Version.v26, 20, HL7Repeat.False, HL7Required.False,"TXA")]
	    public TXA TXA {get;set;}



		#region Parser Helpers and Conrete Impls

        internal override void ConsumeTextSegmentsForGroup(Stack<string> availableData, HL7ParserOptions options) {

			OBX = PopSegmentParseAndCheckRequired<OBX>(availableData, options, "OBX");
			NTE = PopSegmentParseAndCheckRequired<NTE>(availableData, options, "NTE");
			TXA = PopSegmentParseAndCheckRequired<TXA>(availableData, options, "TXA");
        }

		internal override bool CanConsume(string availableData, HL7ParserOptions options)
        {
			bool isOBX = availableData.StartsWith("OBX", StringComparison.OrdinalIgnoreCase);
			if (IsRequired("OBX", options.Version) || isOBX) {
				return isOBX;
			}
			bool isNTE = availableData.StartsWith("NTE", StringComparison.OrdinalIgnoreCase);
			if (IsRequired("NTE", options.Version) || isNTE) {
				return isNTE;
			}
			bool isTXA = availableData.StartsWith("TXA", StringComparison.OrdinalIgnoreCase);
			if (IsRequired("TXA", options.Version) || isTXA) {
				return isTXA;
			}
			return false;
        }

        private static Dictionary<string, bool> SEGMENT_VERSION_REQUIRED_MAP = new Dictionary<string, bool>();

		protected override Dictionary<string, bool> MAP_OF_SEGMENT_TO_REQUIRED
        {
            get
			{
				return SEGMENT_VERSION_REQUIRED_MAP;
			}
        }

		public override string HL7ENTITY_TYPE_NAME
        {
            get {
				return "RESPONSE";
			}
        }

        static RESPONSE_EHC_E13() {

             SetupStaticPropertyMap(SEGMENT_VERSION_REQUIRED_MAP, typeof(RESPONSE_EHC_E13));

        }

		#endregion

		public override string GetER7(HL7ParserOptions options)
		{
			List<string> segmentData = new List<string>();
		 if (OBX != null) {
			string segmentValue = OBX.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
		 if (NTE != null) {
			string segmentValue = NTE.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
		 if (TXA != null) {
			string segmentValue = TXA.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
           return string.Join(HL7ParserConstants.SEGMENT_SEPARATOR, segmentData.ToArray());
        
        }
    }
}

